UI Card: fix and document image as header hero image & content cover#77856
UI Card: fix and document image as header hero image & content cover#77856
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
d0819e2 to
d72f28b
Compare
|
Size Change: +17 B (0%) Total Size: 7.91 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Makes sense to me. Nice change :) |
d72f28b to
df2abb3
Compare
|
Flaky tests detected in 4e6bf90. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25366567366
|
mirka
left a comment
There was a problem hiding this comment.
As I understand it, Header and Content are both just non-semantic containers with padding. So there's no reason to put your image in those containers if it doesn't suit your desired layout.
Of the new cases listed, on first glance there seem to be existing solutions without even using FullBleed:
- As the first child of
Card.Header→ Place the image outside theHeader, directly insideRoot. - As the sole child of
Card.Content→ OmitContentand just place the image directly insideRoot.
If this is true, should these just be documented as patterns in the Storybook examples, rather than adding new styles? The added styles do add a good amount of complexity and testing surface, so ideally we just improve the documentation if valid solutions already exist.
df2abb3 to
24d7858
Compare
|
@mirka nice! Even simpler. I documented the cases in Storybook. I also fixed the missing gap between Good for another look now! |
|
@mirka I see your point about leaner (and pre-existing) solutions for some of these layouts, but I'm wondering if the approach proposed initially (ie. using In other words, I think that, in terms of API clarity and consistency, I'd prefer to give consumers more predictability around how to put a Also, the previous approach allows for more consistent spacing (ensured by Card's internal spacing between Header and Content) |
What?
Card.HeaderandCard.Contentwhen another element (e.g. an image) precedes the header as the first card childCard.Rootfor hero and cover image layouts, covering four compositions: image with header and content, image with header only, image with content only, and image aloneWhy?
Hero images in cards are a common pattern, e.g.:
Full cover images within card containers are also common.
How?
Here's the updated markdown with the direct-in-root pattern from our storybooks:
Usage
Hero image with header title and with content
Just the image as header with content
Header + just the image as content
Just the image as content
The key change across all four:
Card.FullBleedinsideCard.Header/Card.Contentis replaced by placing the image element directly insideCard.Root. Note example 4 flips the order — header first, then the image — which is equally valid sinceCard.Root'soverflow: clipclips any direct child to the card's rounded corners regardless of position.Testing Instructions
See storybook examples:
npm run storybook:devTesting Instructions for Keyboard
Screenshots or screencast
Use of AI Tools